package com.itheima.homework03;

import java.util.Random;

public class RandomNumHandlerDemo {
    public static void main(String[] args) {
        //创建随机数对象
        Random r = new Random();
        useRandomNumHandler(new RandomNumHandler() {
            @Override
            public int getNumber() {
                return r.nextInt(10);
            }
        });

        //lambda表达式,进行简化
        useRandomNumHandler(() -> r.nextInt(10));
    }

    public static void useRandomNumHandler(RandomNumHandler r) {
        System.out.println(r.getNumber());
    }
}
